package com.spring.lo.framework.util;

import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.io.SAXReader;

import java.io.InputStream;

/**
 * 简单实现解析XML文件的工具
 * @author zhangbh
 * 2023-05-28 16:53
 **/
public class DocumentUtils {

    /**
     * 通过文件流获取Document对象
     * @param is 输入流
     * @return Document文档对象
     */
    public static Document createDocument(InputStream is) {
        SAXReader reader = new SAXReader();
        try {
            return reader.read(is);
        } catch (DocumentException e) {
            throw new RuntimeException("xml文件读取异常", e);
        }
    }
}
